package com.service.impl;

import java.util.List;
import javax.annotation.Resource;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mapper.GoodsMapper;
import com.pojo.Goods;
import com.service.GoodsService;

@Service("goodsService")
public class GoodsServiceImpl implements GoodsService {
	@Autowired
	@Resource
	private GoodsMapper goodsMapper;

	@Override
	public Goods find(String id) {
		return goodsMapper.find(id);
	}

	@Override // 继承接口的新增 返回值0(失败),1(成功)
	public int insertGoods(Goods goods) {
		return this.goodsMapper.insertGoods(goods);
	}

	@Override // 继承接口的更新 返回值0(失败),1(成功)
	public int updateGoods(Goods goods) {
		return this.goodsMapper.updateGoods(goods);
	}

	@Override // 继承接口的删除 返回值0(失败),1(成功)
	public int deleteGoods(String goodsid) {
		return this.goodsMapper.deleteGoods(goodsid);
	}

	@Override // 继承接口的查询全部
	public List<Goods> getAllGoods() {
		return this.goodsMapper.getAllGoods();
	}

	@Override // 继承接口的查询全部
	public List<Goods> getGoodsByCate(String cateid) {
		return this.goodsMapper.getGoodsByCate(cateid);
	}

	@Override // 继承接口的查询全部
	public List<Goods> getGoodsByNews() {
		return this.goodsMapper.getGoodsByNews();
	}

	@Override // 继承接口的查询全部
	public List<Goods> getGoodsByHot() {
		return this.goodsMapper.getGoodsByHot();
	}

	@Override // 继承接口的按条件精确查询
	public List<Goods> getGoodsByCond(Goods goods) {
		return this.goodsMapper.getGoodsByCond(goods);
	}

	@Override // 继承接口的按条件模糊查询
	public List<Goods> getGoodsByLike(Goods goods) {
		return this.goodsMapper.getGoodsByLike(goods);
	}

	@Override // 继承接口的按主键查询 返回pojo实例
	public Goods getGoodsById(String goodsid) {
		return this.goodsMapper.getGoodsById(goodsid);
	}

	@Override//分页查询
	public PageInfo<Goods> findAll(Integer pageNow, Integer pageSize) {
		PageHelper.startPage(pageNow,pageSize);
		List<Goods> goods=goodsMapper.getAllGoods();
		PageInfo<Goods>  pageInfo=new PageInfo<>(goods);
		return pageInfo;
	}

}
